Skip to content

Conversation

@acejam
Copy link
Contributor

@acejam acejam commented Nov 17, 2025

This PR adds a configurable fallback request timeout to the Gateway handler.

  • Introduces fallbackRequestTimeout (default 1h) used in handler.ServeHTTP instead of a hardcoded time.Hour
  • Reads optional env var BOXO_GATEWAY_REQUEST_TIMEOUT at init (Go duration format: "90m", "2h", "5400s")
  • Logs a warning and keeps default if the env value is invalid or non-positive
  • Purpose: prevent long CAR streams or large responses from being truncated at exactly 1 hour due to a hardcoded context deadline

Impact

  • Default behavior remains 1 hour unless BOXO_GATEWAY_REQUEST_TIMEOUT is set
  • Allows deployments to extend or disable (by setting a very large duration) the hard per-request cap independent of RetrievalTimeout

Usage

# Example: raise fallback request timeout to 3 hours
export BOXO_GATEWAY_REQUEST_TIMEOUT="3h"

@acejam acejam requested review from a team and lidel as code owners November 17, 2025 19:33
@codecov
Copy link

codecov bot commented Nov 17, 2025

Codecov Report

❌ Patch coverage is 28.57143% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 61.20%. Comparing base (e71f50e) to head (6ad03bd).

Files with missing lines Patch % Lines
gateway/handler.go 28.57% 4 Missing and 1 partial ⚠️

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1069      +/-   ##
==========================================
- Coverage   61.25%   61.20%   -0.05%     
==========================================
  Files         268      268              
  Lines       26284    26290       +6     
==========================================
- Hits        16100    16092       -8     
- Misses       8507     8519      +12     
- Partials     1677     1679       +2     
Files with missing lines Coverage Δ
gateway/handler.go 77.16% <28.57%> (-0.76%) ⬇️

... and 8 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Member

@lidel lidel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Allowing users to override or remove 1h timeout here is a sensible feature, but wiring it up needs to be done in Config (see comment below)


### Added

- `gateway`: Added a configurable fallback timeout for the gateway handler, defaulting to 1 hour, overridable via the BOXO_GATEWAY_REQUEST_TIMEOUT environment variable.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@acejam The existing gateway configuration uses a boxo/gateway/Config struct with explicit fields (e.g., RetrievalTimeout, MaxConcurrentRequests). Using an environment variable is inconsistent with the established pattern and we can't merge this in this form.

Consider adding MaxRequestDuration to the Config struct instead? This would be consistent with how other timeouts are configured and allows programmatic

@hsanjuan hsanjuan added the need/author-input Needs input from the original author label Nov 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

need/author-input Needs input from the original author

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants